#ifndef _ARSObject_H
#define _ARSObject_H

//#include <QString>
//#include <QStringList>
//#include <QtGlobal>
#include <QDateTime>
#include <QStringList>

#include "arsexpression.h"

/*! \class ARSObject
    \brief Contains information about unit's history.
    Contains name of the unit, its change history, owner name
    and the name of the person who was last who modifyed the unit.
*/
class ARSObject : public QObject
{
    Q_OBJECT

    Q_PROPERTY(QString name READ name WRITE setName)
    Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate)
    Q_PROPERTY(QDateTime modifiedDate READ modifiedDate WRITE setModifiedDate)
    Q_PROPERTY(QString createdBy READ createdBy WRITE setCreatedBy)
    Q_PROPERTY(QString modifiedBy READ modifiedBy WRITE setModifiedBy)
    Q_PROPERTY(QStringList changeHistory READ changeHistory WRITE setChangeHistory)
    Q_PROPERTY(QString helpText READ helpText WRITE setHelpText)

    public:
    /*! \enum Type
         ARSObject subclass type. Returned by int type(). \sa virtual Type type()
    */
    enum Type
    {
        /*! ARS form. \sa ARSForm */
        Form           = 1,
        /*! ARS field. \sa ARSFormField */
        Field          = 2,
        /*! ARS guide. \todo not emplemented */
        Guide          = 4,
        /*! ARS active link. \sa ARSActiveLink */
        ActiveLink     = 8,
        /*! ARS filter. \sa ARSFilter */
        Filter         = 16
    };

    Q_DECLARE_FLAGS(Types, Type)

    ARSObject(QObject * parent = 0);

    virtual Type type() const = 0;

    QString name() const;
    void setName(const QString & name);
    QDateTime createDate() const;
    void setCreateDate(const QDateTime & date);
    QDateTime modifiedDate() const;
    void setModifiedDate(const QDateTime & date);
    QString createdBy() const;
    void setCreatedBy(const QString & userName);
    QString modifiedBy() const;
    void setModifiedBy(const QString & userName);
    QStringList changeHistory() const;
    void setChangeHistory(const QStringList & text);
    QString helpText() const;
    void setHelpText(const QString & text);

private:
    QString m_name;
    QDateTime m_createDate;
    QDateTime m_modifiedDate;
    QString m_createdBy;
    QString m_modifiedBy;
    QStringList m_changeHitory;
    QString m_helpText;
};

Q_DECLARE_METATYPE(ARSObject::Types)
Q_DECLARE_OPERATORS_FOR_FLAGS(ARSObject::Types)

typedef QList<ARSObject *> ARSObjectList;

class ARSWorkflowObject : public ARSObject
{
    Q_PROPERTY(ARSExpr * runIf READ runIf WRITE setRunIf)
    Q_OBJECT

public:
    ARSWorkflowObject(QObject * parent = 0);

    ARSExpr * runIf() const;
    void setRunIf(ARSExpr * runIf);

private:
    ARSExpr * m_runIf;
};

typedef QList<ARSWorkflowObject *> ARSWorkflowObjectList;

class ARSActiveLink : public ARSWorkflowObject
{
    Q_OBJECT

public:
    ARSActiveLink(QObject * parent = 0);

    Type type() const;
};

typedef QList<ARSActiveLink *> ARSActiveLinkList;

class ARSFilter : public ARSWorkflowObject
{
    Q_OBJECT

public:
    ARSFilter(QObject * parent = 0);

    Type type() const;
};

typedef QList<ARSFilter *> ARSFilterList;

class ARSField : public ARSObject
{
    Q_OBJECT

    Q_PROPERTY(int id READ id WRITE setID)

public:
    ARSField(QObject * parent = 0);
    void setID(int id);
    int id();

    Type type() const;

private:
    int m_id;
};

typedef QList<ARSFilter *> ARSFilterList;


#endif /* _ARSObject_H */
